package com.szrt.javaweb.ioc.demo05.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.szrt.javaweb.ioc.demo05.dao.CatDao;
import com.szrt.javaweb.ioc.demo05.service.CatService;


@Service
public class CatServiceImpl implements CatService {
	
	//private  CatDao dao = new CatDaoImpl();
	
	
	/**
	 * 当加了@Autowired这个注解后。 
	 * Spring容器 会自动帮你new出CatDao的实现类。把new出来的实现类赋值给dao 也就是说把指针指向 dao.
	 * 此时dao指向的是一个具体的实现类...
	 */
	@Autowired
	private CatDao dao;

	@Override
	public int insert(String name) {
		System.out.println(dao);
		dao.add(name);
		return 0;
	}

	
	public CatServiceImpl(){
		System.out.println("调用CatServiceImpl的构造方法....");
	}
}
